# import the necessary packages
import argparse
import cv2 as cv

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())

# load the image,grab its dimensions,and show it
image = cv.imread(args["image"])
(h, w) = image.shape[:2]
cv.imshow("Original", image)
cv.waitKey(0)
# images are just Numpy arrays. The top-left pixel can be found at (0,0)
(b, g, r) = image[0, 0]
print("Pixel at (0,0) - Red: {r},Green: {g},Blue: {b}".format(r=r, g=g, b=b))

# now,let's change the value of the pixel at (0,0) and make it red
image[0, 0] = (0, 0, 255)
(b, g, r) = image[0, 0]
print("Pixel at (0,0) - Red: {r}, Green: {g},Blue: {b}".format(r=r, g=g, b=b))

# compute the conter of the image,which is simply the width and height
# diveided by two
(cX, cY) = (w // 2, h // 2)

# since we are using Numpy Arrays,we can apply slicing and grab large chunks
# of the image -- let's grab the top-left corner
t1 = image[0:cY, 0:cX]
cv.imshow("TopLeft Corner", t1)
cv.waitKey(0)
# in a similar fashion,let's grab the top-right,bottom-right,and bottom-left
# corners and display them
tr = image[0:cY, cX:w]
br = image[cY:h, cX:w]
bl = image[cY:h, 0:cX]
cv.imshow("Top-Right Corner", tr)
cv.imshow("Bottom-Right Corner", br)
cv.imshow("Bottom-Left Corner", bl)
cv.waitKey(0)
# now let's make the top-left corner of the original image green
image[0:cY, 0:cX] = (0, 255, 0)

# show our updated image
cv.imshow("Updated", image)
cv.waitKey(0)

b, g, r = image[225, 111]
print("r = {r},g = {g},b = {b}".format(b=b, g=g, r=r))
